import { ClassProxy } from "../../../com/gengine/core/ClassProxy";
import { Global } from "../../../com/gengine/global/Global";
import { PathConst } from "./PathConst";
import { PHPSender } from "../../../extend/php/PHPSender";
import { ObjectParser } from "../../../com/gengine/utils/ObjectParser";
type int = number;
//class ParamsConst

export class ParamsConst extends ClassProxy {
  [key: string]: any;
  constructor() {
    
    super();if (ParamsConst._instance != null) {
      throw new Error(" ParamsConst 单例 ");
    }
  }

  /* internal  */ setDebugModle(arg1: any): void {
    if (arg1.hasOwnProperty("isDebug")) {
      if (arg1.isDebug == true || arg1.isDebug == "true") {
        Global.isDebugModle = true;
      } else {
        Global.isDebugModle = false;
      }
    } else {
      Global.isDebugModle = false;
    }
    if (arg1.hasOwnProperty("fairylandLevel")) {
      this.fairylandLevel = parseInt(arg1.fairylandLevel);
    }
    if (arg1.hasOwnProperty("isLocalCache")) {
      if (arg1.isLocalCache == true || arg1.isLocalCache == "true") {
        this.isLocalCache = true;
      } else {
        this.isLocalCache = false;
      }
    } else {
      this.isLocalCache = false;
    }
    if (arg1.hasOwnProperty("isUIByLevel")) {
      if (arg1.isUIByLevel == true || arg1.isUIByLevel == "true") {
        this.isUIByLevel = true;
      } else {
        this.isUIByLevel = false;
      }
    } else {
      this.isUIByLevel = false;
    }
    if (arg1.hasOwnProperty("isCloseTween")) {
      if (arg1.isCloseTween == true || arg1.isCloseTween == "true") {
        this.isCloseTween = true;
      } else {
        this.isCloseTween = false;
      }
    } else {
      this.isCloseTween = false;
    }
    if (arg1.hasOwnProperty("isAutoEnterGame")) {
      if (arg1.isAutoEnterGame == true || arg1.isAutoEnterGame == "true") {
        this.isAutoEnterGame = true;
      } else {
        this.isAutoEnterGame = false;
      }
    } else {
      this.isAutoEnterGame = false;
    }
    if (arg1.hasOwnProperty("isArenaStatueSpecial")) {
      if (
        arg1.isArenaStatueSpecial == true ||
        arg1.isArenaStatueSpecial == "true"
      ) {
        this.isArenaStatueSpecial = true;
      } else {
        this.isArenaStatueSpecial = false;
      }
    } else {
      this.isArenaStatueSpecial = false;
    }
    if (arg1.hasOwnProperty("isArenaStatueShow")) {
      if (arg1.isArenaStatueShow == true || arg1.isArenaStatueShow == "true") {
        this.isArenaStatueShow = true;
      } else {
        this.isArenaStatueShow = false;
      }
    } else {
      this.isArenaStatueShow = true;
    }
    if (arg1.hasOwnProperty("isShowError")) {
      if (arg1.isShowError == true || arg1.isShowError == "true") {
        this.isShowError = true;
      } else {
        this.isShowError = false;
      }
    } else {
      this.isShowError = false;
    }
    if (arg1.hasOwnProperty("gameName")) {
      this.gameName = arg1.gameName;
    } else {
      this.gameName = undefined;
    }
  }

  public init(arg1: any /* flash.display.Stage */): void {
    if (arg1) {
      if (this._isInit == false) {
        // loc1 = arg1.loaderInfo.parameters;
        // this.write(loc1);
        this.replaceParam();
        PathConst.mainPath = this.mainPath != null ? this.mainPath : "";
        this._isInit = true;
        // @ts-ignore
        this.time = new Date(parseFloat(this.time) * 1000);
        if (this.payUrl != null) {
          if (this.payUrl.indexOf("#notUserName=") > -1) {
            this.payUrl = this.payUrl.replace("#notUserName=", "");
            this.payUrl = this.payUrl.replace(new RegExp("#", "g"), "&");
          } else {
            this.payUrl =
              this.payUrl.replace(new RegExp("#", "g"), "&") + this.username;
          }
        } else {
          this.payUrl = "";
        }
        if (this.TWHuiLink1.indexOf("#XXHUserName#") > -1) {
          this.TWHuiLink1 = this.TWHuiLink1.replace(
            "#XXHUserName#",
            this.username
          );
        }
        if (this.TWHuiLink2.indexOf("#XXHUserName#") > -1) {
          this.TWHuiLink2 = this.TWHuiLink2.replace(
            "#XXHUserName#",
            this.username
          );
        }
        if (this.TWHuiLink3.indexOf("#XXHUserName#") > -1) {
          this.TWHuiLink3 = this.TWHuiLink3.replace(
            "#XXHUserName#",
            this.username
          );
        }
        if (this.favoritesUrl.indexOf("#XXHUserName#") > -1) {
          this.favoritesUrl = this.favoritesUrl.replace(
            "#XXHUserName#",
            this.username
          );
        }
        ParamsConst.isPay = this.sDocc != 1 ? false : true;
        PHPSender.isCreateRole = this.newUser == 1;
        // this.setDebugModle(true);
      }
    } else {
      this._isInit = false;
      throw new Error("stage == null");
    }
    return;
  }

  /* internal  */ replaceParam(): void {
    var names = ObjectParser.getClassVars(this);
    var i = 0;
    while (i < names.length) {
      var name = names[i];
      if (typeof this[name] === "string") {
        var value = this[name];
        if (value as string) {
          this[name] = value.replace(
            new RegExp("#XXHUserName#", "g"),
            this.username
          );
        }
      }
      ++i;
    }
    return;
  }

  public static get instance(): ParamsConst {
    if (ParamsConst._instance == null) {
      ParamsConst._instance = new ParamsConst();
    }
    return ParamsConst._instance;
  }

  public static /* const */ DefaultPassWord: string = "123456";

  public static /* const */ Version: string = "2.0.8.5";

  public /* var */ player_id!: int;

  public /* var */ userId!: int;

  public /* var */ server!: string;

  public /* var */ time!: Date;

  public /* var */ issm!: int;

  public /* var */ isAdult!: int;

  public /* var */ totalOnlineTime!: number;

  public /* var */ flag!: string;

  public /* var */ defaultCamp!: int;

  public /* var */ defaultSex!: int;

  public /* var */ roleName!: string;

  public /* var */ guest!: int;

  public /* var */ newUser: int = 0;

  public /* var */ version: string = "1.0.0.0";

  public /* var */ flashVersion: string = "1.0.0.0";

  public /* var */ loginIP: string = "192.168.10.91: 9500";

  public /* var */ gameIP!: string;

  public /* var */ mainPath!: string;

  public /* var */ configUrl!: string;

  public /* var */ createRoleUrl: string = "CreateRole.swf";

  public /* var */ gameUrl: string = "MainGame.swf";

  public /* var */ createRoleVersion: string = "";

  public /* var */ password!: string;

  public /* var */ isConnectionServer: Boolean = true;

  public /* var */ dothingUrl!: string;

  public /* var */ phpID!: int;

  public /* var */ payUrl!: string;

  public /* var */ actimUrl!: string;

  public /* var */ bbsUrl!: string;

  public /* var */ proctecUrl!: string;

  public /* var */ xskUrl: string = "http://frxz2.4399.com";

  public /* var */ phoneUrl!: string;

  public /* var */ mobile360Url!: string;

  public /* var */ title!: string;

  public /* var */ gmInfo!: string;

  public /* var */ randomNameUrl!: string;

  public /* var */ loginGiftUrl!: string;

  public /* var */ sDocc!: int;

  public /* var */ fastUrl!: string;

  public /* var */ isOpenMarry: int = 0;

  public /* var */ isOpenFacebook: int = 0;

  public /* var */ issmType: int = 0;

  public /* var */ languageType!: string;

  public /* var */ proxyType!: string;

  public /* var */ isShowFavorites: int = 1;

  public /* var */ favoritesUrl: string = "";

  public /* var */ cacheSetUrl!: string;

  public /* var */ gameName?: string;

  public /* var */ gameMsgURL!: string;

  public /* var */ preLoadPageBg!: string;

  public /* var */ preLoadPageBgCreateRole!: string;

  public /* var */ preLoaderVersion: string = "";

  public /* var */ forgameLogoVersion: string = "";

  public /* var */ preloaders: string = "";

  public /* var */ libraryUrls: string = "";

  public /* var */ isLocalCache: Boolean = false;

  public /* var */ localurl!: string;

  public /* var */ fairylandLevel!: int;

  public /* var */ exploreShopLevel: int = 101;

  public /* var */ chatLimitLevel: int = 35;

  public /* var */ chatPrivateLevel: int = 14;

  public /* var */ gameTipsPath: string = "assets/config/gametips.xml";

  public /* var */ quickRegisterUrl: string =
    "http://frmmo1.my4399.com/f2_game/create_plant_user.php";

  public /* var */ updateUrl: string = "-1";

  public /* var */ gmUrl!: string;

  public /* var */ gmJsFun: string = "";

  public /* var */ gmHelpUrl!: string;

  public /* var */ vipHelpUrl!: string;

  public /* var */ timerTestType: int = 0;

  public /* var */ isShowTWHui: Boolean = false;

  public /* var */ TWHuiLink1: string =
    "http://forum.gamer.com.tw/A.php?bsn=22008";

  public /* var */ TWHuiLink2: string =
    "http://www.gamebase.com.tw/forum/67175";

  public /* var */ TWHuiLink3: string = "https://www.facebook.com/xshfans";

  public /* var */ TWHuiLink1Text: string = "前往巴哈姆特『天啟』專區";

  public /* var */ TWHuiLink2Text: string = "前往遊戲基地『天啟』專區";

  public /* var */ TWHuiLink3Text: string = "前往『天啟』粉絲團";

  public /* var */ TWHuiLinkDesc: string =
    "每天前往遊戲基地討論版、FB粉絲團，與各位仙友交流心得，即可獲得驚喜小禮。";

  public /* var */ TWProxySubType: string = "";

  public /* var */ chatNumLimit: int = 3;

  public /* var */ vipHelpNeedGold: int = 50000;

  public /* var */ whoPlayGameUrl!: string;

  public /* var */ friendPlayGameUrl!: string;

  public /* var */ attentionUrl!: string;

  public /* var */ isShowArenaCrossIcon: Boolean = true;

  private /* var */ _isInit: Boolean = false;

  public /* var */ Mall360GiftUrl: string = "";

  public /* var */ Gift360PetUrl: string = "";

  public /* var */ Gift91Wan!: string;

  public /* var */ isGift360buy: Boolean = false;

  public /* var */ getAnyGiftUrl: string = "";

  public /* var */ currentCity: string = "";

  public /* var */ TW5FBURL: string = "http://www.baidu.com";

  public /* var */ isUIByLevel: Boolean = false;

  public /* var */ isCloseTween: Boolean = false;

  public /* var */ linkActiveTime: string = "";

  public /* var */ linkActiveWebSite: string = "";

  public /* var */ isAutoEnterGame: Boolean = false;

  public /* var */ linkUrl: string = "";

  public /* var */ linkIcon: string = "LinkBtn";

  public /* var */ isNewServer!: int;

  public /* var */ linkIconNewServer: string = "LinkBtnNewServer";

  public /* var */ isArenaStatueSpecial: Boolean = false;

  public /* var */ isArenaStatueShow: Boolean = true;

  public /* var */ isNoNeedServer: Boolean = false;

  public /* var */ isShowError: Boolean = false;

  public /* var */ vip360Url: string = "";

  public /* var */ vip360GetUrl: string = "";

  public /* var */ isPeriShow: int = 1;

  public /* var */ isShowQrIco: int = 0;

  public /* var */ platformCode!: string;

  public /* var */ platformUserName!: string;

  public static /* var */ isPay: Boolean = true;

  private static /* var */ _instance: ParamsConst;

  public /* var */ username!: string;

  public /* var */ linkUrlNewServer: string = "";
}
